#include<iostream>
#include<algorithm>
using namespace std;
const int N = 110, INF = 0x3f3f3f3f;
int w[N][N];
int f[N][N];
int n;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> w[i][j];
		}
	}
	memset(f, INF, sizeof(f));
	f[1][1] = w[1][1];
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (i > 1) {	
				f[i][j] = min(f[i][j], f[i - 1][j] + w[i][j]);
			}
			if (j > 1) {
				f[i][j] = min(f[i][j], f[i][j - 1] + w[i][j]);
			}
		}
	}
	cout << f[n][n] << endl;
	return 0;
}